import {
  PIC_SERVER,
  PIC_DEV_SERVER,
  DEBUG
} from '../constants/setting'

export default function getFullPath ({ path, size = '430x430', prefix = 'product' }) {
  let fullPath
  if (path.startsWith('http')) {
    fullPath = path
  } else {
    fullPath = DEBUG ? PIC_DEV_SERVER : PIC_SERVER
    fullPath += `/${prefix}/`
    fullPath += size.replace(/^(\d+)x(\d+)$/, '/$1/$2/')
    fullPath += `/${path}`
  }
  return fullPath
}
